<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
  <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>管理员登录</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="layui/layui/css/layui.css"  media="all">
</head>
<body>
<div align="center">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>管理员登录</legend>
</fieldset>
</div>
<form class="layui-form"  id="myform" method="post">
<div style="width:24%">
  <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-block">
      <input type="text" name="loignname" id="loignname" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input">
    </div>
    <br><br>
    <label class="layui-form-label">密码</label>
    <div class="layui-input-block">
      <input type="text" name="password" id="password" lay-verify="title" autocomplete="off" placeholder="请输入密码 " class="layui-input">
    </div>
     <br><br>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <input class="layui-btn" id="submitbtn" lay-filter="demo1" type="button" value="登录">
    </div>
  </div>
</div>
</form>
<script src="layui/layui/layui.js" charset="utf-8"></script>
<script>
layui.use(['jquery', 'layer'], function() {
	var $ = layui.$;
	var layer = layui.layer;
	
	// 点击提交按钮
	$('#submitbtn').click(function() {
		var uname = $('#loignname').val();
		var passwd = $('#password').val();
		if(uname=='' || passwd=='') {
			alert('账号或密码不能为空');
			return false;
		}
		
		var params = $('#myform').serialize();
		$.post('${path}/action/adLogin/login', params, function(data) {
			if(data.success) {
				//alert(JSON.stringify(data));
				window.location.href = 'index.jsp';		
			} else {
				layer.msg(data.msg);
			}
		}, 'json');
	});
	
})
</script>
</body>
</html>